/*******************************************************************************
Replication Materials for Blau, Kahn, Brummund, Cook, and Larson-Koester "Is 
There Still Son Preference in the United States?"

Table R11 - Table 4 with ACS Sample Range (2008-2013)

See "CPS Read Me" for variable definitions

Date Modified: 10/21/2019

*******************************************************************************/

*Define needed variables
local v "head_samp secgen imm_gen core_samp core_sampf citizen"
local v "`v' hhwtnorm lths scol cold sp_lths sp_scol sp_cold genrace sp_genrace"
local v "`v' region year age* sp_age* chld1 gt0chld femhdalt nchild"

*Load Data
use `v' using "$cps\regfile_March_core", clear

*Keep only those who are a household head or spouse of the household head
keep if head_samp == 1

*Restrict Years
keep if inrange(year, 2008, 2013)==1

*Note additional restrictions made in regressions

label var chld1 "First Child Girl"

/*******************************************************************************

I. Natives

*******************************************************************************/

*Living Without a Father

local sample "if imm_gen==3 & citizen!=1 & gt0chld==1 & core_samp==1"

local wgt "hhwtnorm"

local controls "lths scol cold"
local controls "`controls' i.genrace i.region i.year age age2 age3"

local main "chld1"

reg femhdalt `main' `controls' `sample' [aw=`wgt'], robust
qui sum femhdalt `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R11.xls", keep(`main') title("Table R11: Effects of Female First Child on Probability of Living Without a Father and Fertility by Immigrant Generation (2008-2013)")ctitle(3rd+ No Dad) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 replace


*Fertility

local sample "if imm_gen==3 & citizen!=1 & gt0chld==1 & core_sampf==1"

local wgt "hhwtnorm"

local controls "lths scol cold sp_lths sp_scol sp_cold" 
local controls "`controls' i.genrace i.sp_genrace i.region i.year age age2 age3" 
local controls "`controls' sp_age sp_age2 sp_age3" 

local main "chld1"

reg nchild `main' `controls' `sample' [aw=`wgt'], robust
qui sum nchild `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R11.xls", keep(`main') ctitle(3rd+ Fertility) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 append



/*******************************************************************************

II. Immigrants

*******************************************************************************/

*Living Without a Father

local sample "if imm_gen==1 & citizen!=1 & gt0chld==1 & core_samp==1"

local wgt "hhwtnorm"

local controls "lths scol cold"
local controls "`controls' i.genrace i.region i.year age age2 age3"

local main "chld1"

reg femhdalt `main' `controls' `sample' [aw=`wgt'], robust
qui sum femhdalt `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R11.xls", keep(`main') ctitle(1st No Dad) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 append


*Fertility

local sample "if imm_gen==1 & citizen!=1 & gt0chld==1 & core_sampf==1"

local wgt "hhwtnorm"

local controls "lths scol cold sp_lths sp_scol sp_cold" 
local controls "`controls' i.genrace i.sp_genrace i.region i.year age age2 age3" 
local controls "`controls' sp_age sp_age2 sp_age3" 

local main "chld1"

reg nchild `main' `controls' `sample' [aw=`wgt'], robust
qui sum nchild `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R11.xls", keep(`main') ctitle(1st Fertility) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 append


/*******************************************************************************

III. Second Generation

*******************************************************************************/

*Living Without a Father

local sample "if imm_gen==2 & citizen!=1 & gt0chld==1 & core_samp==1"

local wgt "hhwtnorm"

local controls "lths scol cold"
local controls "`controls' i.genrace i.region i.year age age2 age3"

local main "chld1"

reg femhdalt `main' `controls' `sample' [aw=`wgt'], robust
qui sum femhdalt `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R11.xls", keep(`main') ctitle(2nd No Dad) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 append


*Fertility

local sample "if imm_gen==2 & citizen!=1 & gt0chld==1 & core_sampf==1"

local wgt "hhwtnorm"

local controls "lths scol cold sp_lths sp_scol sp_cold" 
local controls "`controls' i.genrace i.sp_genrace i.region i.year age age2 age3" 
local controls "`controls' sp_age sp_age2 sp_age3" 

local main "chld1"

reg nchild `main' `controls' `sample' [aw=`wgt'], robust
qui sum nchild `sample'  [aw=`wgt']
local dep_mean : display %9.4f r(mean)
local pct_effect : display %9.4f (_b[chld1]/r(mean))*100
outreg2 using "$routput\Table R11.xls", keep(`main') ctitle(2nd Fertility) addtext(Mean, `dep_mean', Pct. Effect, `pct_effect') label dec(4) nocons nor2 append


